package com.example.fw;

import static org.junit.Assert.fail;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebDriverHelper {
	
	static WebDriver driver;
	protected final ApplicationManager manager;
	private StringBuffer verificationErrors = new StringBuffer();

	public WebDriverHelper(ApplicationManager manager) {
		this.manager = manager;	
		//proxy.setNoProxy("localhost");
		//Proxy proxy = new Proxy();
		//proxy.setHttpProxy("localhost:8888");
		//DesiredCapabilities capabilities = new DesiredCapabilities();
		//capabilities.setCapability("proxy", proxy);
		//driver = new FirefoxDriver(capabilities);
		
		driver = new FirefoxDriver();
		//driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		openUrl("http://localhost/addressbookv4.1.4/");
	}
	private void openUrl(String string) {
		driver.get(string);
	}
	public void stop() {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}
	public WebDriver getDriver() {
		return driver;
	}
}
